<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../../commons/taglib.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>门诊</title>
    <link type="text/css" rel="stylesheet" href="${ctx}/static/js/bootstrap.min/css/bootstrap.min.css">
    <script type="text/javascript" src="${ctx}/static/js/jq/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="${ctx}/static/js/bootstrap.min/js/bootstrap.min.js"></script>
    <link type="text/css" rel="stylesheet" href="${ctx}/static/css/mz.css">

</head>
<body>
    <div class="body">
	<form action="chufang" method="post">
        <div class="top" style="margin-bottom: 20px;">
            <div class="p left">就诊详情</div>
            <div class="right">
            	<button class="btn btn-default daiz" type="button">待诊</button>
            	<button class="btn btn-default jlbl" type="button">建立病例</button>
                <button class="btn btn-default blbc1" type="button">保存</button>
                <button class="btn btn-default blbc2" type="button">保存</button>
                <button class="btn btn-info price" type="button">收费</button>
                <button class="btn btn-info" type="button">新建病人</button>
                <button class="btn btn-info" type="button">打印</button>
            </div>
       </div>
        <div class="clear"></div>
        <div class="top-t">
            <ul>
                <li>电子处方</li>
                <li>电子病历</li>
                <%--<li>检验检查</li>--%>
            </ul>
        </div>
        <div class="index n1">
            <div class="xtop">
                <div class="dropdown left">
                    <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                        添加处方
                        <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu addff" aria-labelledby="dropdownMenu1">
                        <li>西药处方</li>
                        <li>中药处方</li>
                    </ul>
                </div>
                <div class="cf">西药处方<span class="xc">x</span></div>
            </div>
            <div class="clear"></div>
            <!--添加处方body-->
            <div class="i-body left">
                <div class="append">
                    <h3 class="i-title left">西药处方</h3>
                    <div class="right op">
                        <select class="select left" >
                        	<option>普通</option>
                        	<option>急诊</option>
                        </select>
                    </div>
                    <div class="clear"></div>
                    <div class="neirong">
                        <span class="left">就诊号：</span><input style="background: #D3D0D8;" readonly="readonly" class="input left noborder jz" name="id">
                        <span class="left">费别：</span><input style="background: #D3D0D8;" readonly="readonly" class="input left noborder jz">
                        <!--<select class="select left noborder">
                        	<option>普通</option>
                        </select>-->
                        <span class="left">卡号:</span>
                        <input style="background: #D3D0D8;" readonly="readonly" class="input left wll noborder">
                        <span class="left">就诊:</span><input style="background: #D3D0D8;" readonly="readonly" class="input left noborder jz">
                        <!--<select class="select left noborder" >
                            <option>初诊</option>
                        </select>-->
                        </div>
                    <div class="clear"></div>
                    <div class="neirong">
                        <span class="left">姓名：</span><input style="background: #D3D0D8;"  readonly="readonly" class="input left noborder">
                        <span class="left">性别：</span><input style="background: #D3D0D8;" readonly="readonly" class="input left noborder jz">
                    </div>
                    <div class="neirong">
                        <span class="left">电话：</span><input style="background: #D3D0D8;" readonly="readonly" class="input left wl noborder">
                    </div>
                <div class="neirong">
                    <span class="left">诊断：</span><input name="diagnosis" class="input left wll noborder zd" value="无">
                    <span class="left">过敏史：</span><input name="allergy" class="input left wll noborder gms" value="无">
                </div>
                <div class="neirong tbs">
                    <h3>Rp</h3>
                    <!-- <form class="form"> -->
                    <table class="table apss">
                        <tr>
                            <th>序号</th>
                            <th>名称</th>
                            <th>一次用量</th>
                            <th>用法</th>
                            <th>频率</th>
                            <th>总量</th>
                            <th>操作</th>
                        </tr>
                    </table>
                    <!-- </form> -->
                    </div>
                <div class="neirong foots">
                 <div class="btn btn-default left">附加费</div>
                    <div class="left">
                        <span class="left">共<span class="prs">x</span>个处方单；总价：￥<span class="pr1">x</span>当前处方总价：￥<span class="pr2">x</span>；科室：</span>
                        <select class="select left">
                            <option>全科门诊</option>
                            <option>全科门诊</option>
                        </select>
                        <span class="left">；医生：</span>
                        <select class="select left">
                            <option>全科门诊</option>
                            <option>全科门诊</option>
                        </select>
                    </div>
                </div>
                </div>
                </div>

	    <div class="tjp">
	        <div class="panel panel-default">
	            <div class="page-header"><div class="left">确认收费</div><span class="right cxp" style="cursor: pointer;">X</span> <div class="clear"></div></div>
	            <div class="panel-body">
	                <span class="left"> 应收价格：</span>
	                <input class="input left prs" name="amount" style="background: #D3D0D8;color: red;" type="number" readonly="readonly" value="">
	                <div class="clear"></div>
	            </div>
	            <div class="panel-footer">
	                <button class="btn btn-info right cxp"  type="submit">确定</button>
	                <button class="btn btn-main right cxp"  type="button">取消</button>
	                <div class="clear"></div>
	            </div>
	        </div>
	    </div>

        <!-- 添加处方right -->
            <div class="ap-r" style="margin-top: 10px;">
                <div class="tops1">
                    <div class="tops-t">
                        <button class="btn btn-default xl" type="button">药品</button>
                        <button class="btn btn-default xl" type="button">项目</button>
                    </div>
                    <div class="xiangmu" style="overflow:auto;height:90%;position: relative;">
                        <div class="input-group col-xs-6">
                            <input type="text" id="yp_search" class="form-control" placeholder="搜索药品" aria-describedby="basic-addon2">
							<a class="button border-main icon-search input-group-addon but" > 搜索</a>
                        </div>
                        <table class="table rz yp_table" >
                            <tr>
                                <th style="width: 10%">ID</th>
                                <th>名称</th>
                                <th>规格</th>
                                <th>库存</th>
                                <th>单价</th>
                            </tr>
                            <c:forEach items="${ drug }" var="list">
                                <tr class="tdt">
                                    <%-- <td><input class="checkbox" type="checkbox" style="float: left;">${list.id }</td> --%>
                                    <td>${list.id }</td>
                                    <td>${list.name }</td>
                                    <td>${list.spec }</td>
                                    <td>${list.tory }</td>
                                    <td>${list.price }</td>
                                </tr>
                            </c:forEach>
                        </table>
                        <div class="pagelist">
							<%-- <%if(){} %> --%>
							<input type="button" class="pags" id="" value="上一页" />	
						
							<label style="color: blueviolet;" type="button" class="pag" id="" >${pageNumber}</label>&nbsp;&nbsp;&nbsp;
						
							<label style="color: blueviolet;" type="button" class="pag2" id="">${pageNumber+1}</label>
						
							<input type="button" class="pagx" id="" value="下一页"/>
							
							总共<label id="lable" style="color: red;">${Pages}</label>页
							
						</div>
                        <div style="clear: both;"></div>
                    </div>
                    <div class="xiangmu" style="overflow:auto;height:85%;position: relative;">
                        <div class="input-group col-xs-6">
                            <input id="xmser" type="text" class="form-control" placeholder="搜索项目" aria-describedby="basic-addon3">
                            <a class="input-group-addon cut" id="basic-addon3 add-xm2">添加</a>
                        </div>
                        <table class="table rz xm_table">
                            <tr>
                            	<th style="width: 15%">ID</th>
                                <th>名称</th>
                                <th>价格</th>
                            </tr>
                            <c:forEach items="${ project }" var="list">
                            <tr class="tdu">
                            	<td>${list.id }</td>
                                <td>${list.name }</td>
                                <td>${list.price }</td>
                            </tr>
                             </c:forEach>
                        </table>
                    </div>
                </div>
            </div>
    </form>
        <div class="clear"></div>
    </div>
        <div class="index n2">
            <div class="i-bodys left">
                <div class="neirong inpadd">
                    <div class="ds">
                        <span class="left">就诊号：</span><input style="background: #D3D0D8;" readonly="readonly" class="input left">
                        <span class="left">就诊：</span>
                        <input style="background: #D3D0D8;" readonly="readonly" class="input left">
                        <span class="left">费别：</span>
                        <input style="background: #D3D0D8;" readonly="readonly" class="input left">
                        <span class="left">卡号：</span><input style="background: #D3D0D8;" readonly="readonly" class="input left wl">
                    </div>
                    <div class="clear"></div>

                    <div class="ds">
                        <span class="left">姓名：</span><input readonly="readonly" class="input left" style="width: 115px; background: #D3D0D8;">
                        <span class="left">性别：</span>
                        <input style="background: #D3D0D8;" readonly="readonly" class="input left">
                        <span class="left">电话：</span><input  readonly="readonly" class="input left" style="width: 300px; background: #D3D0D8;">
                    </div>
                    <div class="clear"></div>
                    <div class="ds">
                        <span class="left">诊断：</span><input readonly="readonly" class="input left wll" style="width: 266px; background: #D3D0D8;">
                    	<span class="left" style="color: red;">过敏史：</span>
                        <input  readonly="readonly" class="input wll left" value="" style="width: 285px;color: red; background: #D3D0D8;">
                    </div>
                    <div class="clear"></div>
                </div>
                <div class="clear"></div>
                <div class="neirong xia">
                    <button class="btn btn-info xyb">西医病历</button>
                    <button class="btn btn-info zyb">中医病历</button>
                    <div class="xybl">
                    <!--//改2-->
                    <form id="form1">
                        <div class="tn">
                            <div class="left vs">
                            <input id="blid" name="id" type="hidden"/>
                            <div>主诉</div>
                            	<textarea class="tex" name="cc"></textarea>
                             </div>
                            <div class="left vs">
                                <div>现病史</div>
                                <textarea class="tex" name="hpi"></textarea>
                            </div>
                        </div>
                        <div class="tn">
                            <div class="left vs">
                                <div>家族史</div>
                                <textarea class="tex" name="family"></textarea>
                            </div>
                            <div class="left vs">
                                <div>辅助检查</div>
                                <textarea class="tex" name="auxiliary"></textarea>
                            </div>
                        </div>
                        <div class="tn">
                            <div class="left vs">
                                <div>诊断</div>
                                <textarea class="tex" name="diagnosis"></textarea>
                            </div>
                            <div class="left vs">
                                <div>处理意见</div>
                                <textarea class="tex" name="opinion"></textarea>
                            </div>
                        </div>
                         <div class="tn">
                            <div class="left vs">
                                <div>医嘱</div>
                                <textarea class="tex"  name="advice"></textarea>
                            </div>
                            <div class="left vs">
                                <div>备注</div>
                                <textarea class="tex" name="note"></textarea>
                            </div>
                        </div>
                        </form>
                    <div class="clear"></div>
                    </div>
                    
                <form id="form2">
                    <div class="zybl">
                        <div class="tn">
                        	<input id="blid" name="id" type="hidden"/>
                            <div class="left vs">
                            <div>主诉</div>
                            <textarea class="tex" name="cc"></textarea>
                             </div>
                            <div class="left vs">
                                <div>现病史</div>
                                <textarea class="tex" name="hpi"></textarea>
                            </div>
                        </div>
                        <div class="tn">
                            <div class="left vs">
                                <div>家族史、既往史</div>
                                <textarea class="tex" name="family"></textarea>
                            </div>
                            <div class="left vs">
                                <div>望闻问切</div>
                                <textarea class="tex" name="listening"></textarea>
                            </div>
                        </div>
                        <div class="tn">
                            <div class="left vs">
                                <div>辅助检查</div>
                                <textarea class="tex" name="auxiliary"></textarea>
                            </div>
                            <div class="left vs">
                                <div>辨证分析</div>
                                <textarea class="tex" name="analysis"></textarea>
                            </div>
                        </div>
                        <div class="tn">
                            <div class="left vs">
                                <div>诊断</div>
                                <textarea class="tex" name="diagnosis"></textarea>
                            </div>
                            <div class="left vs">
                                <div>处理意见</div>
                                <textarea class="tex" name="opinion"></textarea>
                            </div>
                        </div>
                        <div class="tn">
                            <div class="left vs">
                                <div>医嘱</div>
                                <textarea class="tex" name="advice"></textarea>
                            </div>
                            <div class="left vs">
                                <div>备注</div>
                                <textarea class="tex" name="note"></textarea>
                            </div>
                        </div>
                </form>
                    <div class="clear"></div>
                    </div>
                </div>
            </div>
            <div class="ap-r" style="margin-top: 10px;">
                <div class="">
                    <div class="xiangmu" style="display: block;">
                        <div class="input-group col-xs-6">
                            <input  type="text" class="form-control" placeholder="搜索药品" aria-describedby="basic-addon4">
                            <span class="input-group-addon add-xm" id="basic-addon4 add-xm">搜索</span>
                        </div>
                        <table class="table rz">
                            <tbody><tr>
                                <th>#</th>
                                <th>名称</th>
                                <th>操作</th>
                            </tr>
                            <tr>
                                <td></td>
                                <td>名称</td>
                                <td>1</td>
                            </tr>
                            </tbody></table>
                    </div>
                </div>
            </div>
            <div class="clear"></div>
        </div>
    </div>
    
    <div class="guahao">
        <div class="panel panel-default">
            <div class="panel-heading"><span class="left">已挂号待就诊人员</span><span class="right daizx">X</span><div class="clear"></div></div>
            <div class="panel-body">
                <table class="table">
                    <tr>
                        <th>诊号</th>
                        <th>费别</th>
                        <th>姓名</th>
                        <th>性别</th>
                        <th>卡号</th>
                        <th>类型</th>
                        <th>电话</th>
                        <th>操作</th>
                    </tr>
                    <c:forEach items="${ out }" var="list">
                        <tr>
                            <td>${list.id }</td>
                            <td>${list.category }</td>
                            <td>${list.name }</td>
                            <td>${list.sex }</td>
                            <td>${list.id }</td>
                            <td>${list.c_type }</td>
                            <td>${list.phone }</td>
                            <td><a class="xtian" id="${list.id }">选择</a></td>
                        </tr>
                    </c:forEach> 
                </table>
            </div>
        </div>
    </div>
    
    <div class="bljz" >
        <div class="panel panel-default">
            <div class="panel-heading"><span class="left">待写病例人员</span><span class="right daizxq" style="cursor: pointer;">X</span><div class="clear"></div></div>
            <div class="panel-body">
                <table class="table" style="cursor: pointer;">
                    <tr>
                        <th>诊号</th>
                        <th>费别</th>
                        <th>姓名</th>
                        <th>性别</th>
                        <th>卡号</th>
                        <th>类型</th>
                        <th>电话</th>
                        <th>诊断</th>
                        <th>过敏史</th>
                        <th>操作</th>
                    </tr>
                    <c:forEach items="${ cases }" var="list">
                        <tr>
                            <td>${list.id }</td>
                            <td>${list.category }</td>
                            <td>${list.name }</td>
                            <td>${list.sex }</td>
                            <td>${list.id }</td>
                            <td>${list.c_type }</td>
                            <td>${list.phone }</td>
                            <td>${list.diagnosis }</td>
                            <td style="color: red;">${list.allergy }</td>
                            <td><a class="blcz" id="${list.id }">选择</a></td>
                        </tr>
                    </c:forEach> 
                </table>
            </div>
        </div>
    </div>
    
<script type="text/javascript">
	
    $('.index').eq(0).show();
    $('.xiangmu').eq(0).show();
    $('c1').show();
    $('.zybl').hide();
    
    $('.daiz').click(function () {
        $('.guahao').show();
    })
    //改3
    $('.jlbl').click(function () {
    	$('.bljz').show();
    })
    $('.jlbl').hide();
    $('.daizxq').click(function () {
        $('.bljz').hide();
    })
    /*--选择病例人员--*/
    $('.blcz').click(function () {
    	var id = this.id;
    	$('#blid').val(id);
        var gua = $(this).index('.blcz');
        var lens =$('.bljz tr').children('td').length;
        var $arr =[];
        for(var i=0;i<lens-1;i++){
            var hao = $('.bljz tr').eq(gua+1).children().eq(i).text();
            $arr.push(hao);
        }
        var $len=$('.i-bodys').length;
        for(var j=0;j<$len;j++){
            var none = $('.i-bodys').eq(j).css('display');
            if(none=='block'){
                console.log($arr[1],j)
                $('.i-bodys').eq(j).find('input').first().val($arr[0]);//就诊号
                $('.i-bodys').eq(j).find('input').eq(2).val($arr[1]);//费别
                $('.i-bodys').eq(j).find('input').eq(3).val($arr[4]);//卡号
                $('.i-bodys').eq(j).find('input').eq(1).val($arr[5]);//类型
                $('.i-bodys').eq(j).find('input').eq(4).val($arr[2]);//姓名
                $('.i-bodys').eq(j).find('input').eq(5).val($arr[3]);//姓别
                $('.i-bodys').eq(j).find('input').eq(6).val($arr[6]);//电话
                $('.i-bodys').eq(j).find('input').eq(7).val($arr[7]);//电话
                $('.i-bodys').eq(j).find('input').eq(8).val($arr[8]);//电话
            }
        }
        $('.bljz').hide();
    })
    //改1
    $('.daizx').click(function () {
        $('.guahao').hide();
    })
    
    $('.blbc2').hide();
    $('.zyb').click(function () {
        $(this).css({backgroundColor:'#fff',color:'black',borderColor:'#fff'}).prev().css({backgroundColor:'#5bc0de'})
        $('.zybl').show();
        $('.xybl').hide();
        $('.blbc1').hide();
        $('.blbc2').show();
        $('.blbc2').click(function(){
        	$.post('bladd',$('#form1').serialize(),function(e){
        		alert(e);
        		$('.xybl textarea').val("");
        		$('.xybl input').val("");
        		$('.i-bodys input').val("");
			});
        });
    });
    $('.xyb').click(function () {
        $(this).css({backgroundColor:'#fff',color:'black',borderColor:'#fff'}).next().css({backgroundColor:'#5bc0de'})
        $('.xybl').show();
        $('.zybl').hide();
        $('.blbc2').hide();
        $('.blbc1').show();
        $('.blbc1').click(function(){
        	$.post('bladd',$('#form1').serialize(),function(e){
        		alert(e);
        		$('.xybl textarea').val("");
        		$('.xybl input').val("");
        		$('.i-bodys input').val("");
			});
        });
    });
    function chu(e) {
        var show =$('.zybl').css('display');
            if(show=='none'){
                if(e==0){
                    $('.xyblc').show();
                    $('.xybl').hide();
                    $('.zybl').hide();
                }else {
                    $('.xyblc').hide();
                    $('.xybl').show();
                    $('.zybl').hide();
                }
            }
    }
    $('.xx').click(function () {
        $('.c-body').hide();
    })
    $('.xxx').click(function () {
        $('.c-body1').hide();
    })
    $('.cy').click(function () {
        $('.c-body').show();
    })
    $('.tc').click(function () {
        $('.c-body1').show();
    })

    $('.xl').click(function () {
        var index = $(this).index('.xl');
        $('.xiangmu').eq(index).show();
        for( var i = 0;i< $('.xiangmu').length;i++){
            if(i!=index){
                $('.xiangmu').eq(i).hide();
            }
        }
    })
    $('.top-t ul li').click(function () {
        var index = $(this).index('.top-t ul li');
        $(".index").eq(index).show();
  		if(index==1){
  		    $('.daiz').hide();
        	$('.jlbl').show();
  		}
		if(index==0){
  		    $('.jlbl').hide();
        	$('.daiz').show();
  		}
        var len = $('.top-t ul li').length;
        for (var i=0;i<len;i++){
            if(index!=i){
                $(".index").eq(i).hide();
            }
        }
    })
    $('.addff li').eq(0).click(function () {
        var len = $('.i-body').length;
        if(len<8){
        var index = $(this).index('.addff li');
            $('.xtop').append(' <div class="cf">西药处方 <span class="xc">x</span></div>');
            $('.n1 .xtop .cf').last().css({backgroundColor:'red'}).siblings().css({backgroundColor:'#fff'});
            var clon = $('.i-body').eq(0).clone();
            clon.find('h3').eq(0).text('西药处方');
            clon.find('tr').eq(0).nextAll().remove();
            clon.find('input').val('');
            $('.i-body').last().after( clon);
            $('.i-body').hide();
            $('.i-body').eq(len).show();
            $('.n1 .xtop .cf .xc').click(function () {
                var cx =$('.n1 .xtop .cf .xc').length;
                if(cx>1){
                var indexc = $(this).index('.n1 .xtop .cf .xc');
                var $ss = indexc-1;
                $('.cf').eq($ss).css({backgroundColor:'red'}).siblings().css({backgroundColor:'#fff'});
                $('.i-body').hide();
                $('.i-body').eq($ss).show();
                $('.cf').eq(indexc).remove();
                $('.i-body').eq(indexc).remove();
                    $('').get().remove();//防止remove更改 indexc（）的值
                }
            });

            $('.cf').click(function () {
                var indes =  $(this).index('.n1 .xtop .cf');
                $(this).css({backgroundColor:'red'}).siblings().css({backgroundColor:'#fff'});
                $('.i-body').eq(indes).show();
                for(var i=0;i< $('.i-body').length;i++){
                    if(indes!=i){
                        $('.i-body').eq(i).hide();
                    }
                }
            })
        }
    })
    
/*--选择挂号人员--*/
    $('.xtian').click(function () {
        var gua = $(this).index('.xtian');
        var lens =$('.guahao tr').children('td').length;
        var $arr =[];
        for(var i=0;i<lens-1;i++){
            var hao = $('.guahao tr').eq(gua+1).children().eq(i).text();
            $arr.push(hao);
        }
        var $len=$('.i-body').length;
        for(var j=0;j<$len;j++){
            var none = $('.i-body').eq(j).css('display');
            if(none=='block'){
                console.log($arr[1],j)
                $('.i-body').eq(j).find('input').first().val($arr[0]);//就诊号
                $('.i-body').eq(j).find('input').eq(1).val($arr[1]);//费别
                $('.i-body').eq(j).find('input').eq(2).val($arr[4]);//卡号
                $('.i-body').eq(j).find('input').eq(3).val($arr[5]);//类型
                $('.i-body').eq(j).find('input').eq(4).val($arr[2]);//姓名
                $('.i-body').eq(j).find('input').eq(5).val($arr[3]);//姓别
                $('.i-body').eq(j).find('input').eq(6).val($arr[6]);//电话
//              $('.i-body').eq(j).find('select').eq(1).find('option').eq(0).text($arr[1]);//费别
//              $('.i-body').eq(j).find('select').eq(2).find('option').eq(0).text($arr[5]);//类型
//              $('.i-body').eq(j).find('select').eq(3).find('option').eq(0).text($arr[3]);//性别
            }
        }
        $('.guahao').hide();
    })
    $('.addff li').eq(1).click(function () {
        if($('.i-body').length<8){
            var index = $(this).index('.addff li');
            $('.xtop').append(' <div class="cf">中药处方 <span class="xc">x</span></div>');
            $('.n1 .xtop .cf').last().css({backgroundColor:'red'}).siblings().css({backgroundColor:'#fff'});
            var clon = $('.i-body').eq(0).clone();
            clon.find('input').val('');
            clon.find('tr').eq(0).nextAll().remove();
            clon.find('h3').eq(0).text('中药处方');
            clon.find('tr').eq(0).replaceWith("<tr><th>序号</th><th>名称</th><th>用量</th><th></th><th></th><th></th><th>操作</th></tr>")
            $('.i-body').last().after( clon);
            var len = $('.i-body').length;
            $('.i-body').hide();
            $('.i-body').eq(len-1).show();
            $('.n1 .xtop .cf .xc').click(function () {
                if($('.n1 .xtop .cf .xc').length>1){
                    var indexc = $(this).index('.n1 .xtop .cf .xc');
                    var $ss = indexc-1;
                    $('.cf').eq($ss).css({backgroundColor:'red'}).siblings().css({backgroundColor:'#fff'});
                    $('.cf').eq(indexc).remove();
                    $('.i-body').eq(indexc).remove();
                    $('.i-body').hide();
                    $('.i-body').eq($ss).show();
                    $('').get().remove();//防止remove更改 indexc（）的值
                    return false;
                }
                return false;
            });


        $('.cf').click(function () {
            var indes =  $(this).index('.cf');
            $(this).css({backgroundColor:'red'}).siblings().css({backgroundColor:'#fff'});
            $('.i-body').eq(indes).show();
            var lens = $('.i-body').length;
            for(var i=0;i<lens;i++){
                if(indes!=i){
                    $('.i-body').eq(i).hide();
                }
            }
        })
        }
    });
    
    $(document).on('click', '.yp_table tr',function(){
    	var id = $(this).find('td').eq(0).html();
    	var name = $(this).find('td').eq(1).html();
    	var spec = $(this).find('td').eq(2).html();
    	var tory = $(this).find('td').eq(3).html();
    	var price = $(this).find('td').eq(4).html();
    	if(!id){
    		return;
    	}
    	var v ='<tr type="1">';
    	v +='<td id="xh"><input id="inp" type="hidden" name="d_id" value="'+id+'" /> '+ id +'</td>';
    	v +='<td id="mc"><input id="inp" type="hidden" name="d_name" value="'+name+'" />'+name+'</td>';
    	v +='<td><input id="inp" type="hidden" value="'+spec+'" />'+spec+'</td>';
    	v +='<td><input class="input ws yf" value="口服"  name="usage" /></td>';
    	v +='<td><input class="input ws pl" value="3/天" name="dosage" /></td>';
    	v +='<td><input id="zll" class="input ws zl" name="number" value="1" /></td>';
    	v +='<td style="display: none"><input name="tory" type="hidden" value='+tory+'></td>';
    	v +='<td><button type="button" class="btn btn-default delete_a"">删除</button></td>';
    	v +='<td style="display: none"><input id="add" type="hidden" value='+price+'></td>';
    	v +='</tr>';
    	$(".apss").append(v);
    });
    
    $(document).on('click', '.xm_table tr',function(){
    	var id = $(this).find('td').eq(0).html();
    	var name = $(this).find('td').eq(1).html();
    	var money = $(this).find('td').eq(2).html();
    	if(!id){
    		return;
    	}
    	
    	var v ='<tr type="1">';
    	v +='<td id="xh"><input id="inp" type="hidden" name="xd_id" value="'+id+'" /> '+ id +'</td>';
    	v +='<td id="mc"><input id="inp1" type="hidden" name="xd_name" value="'+name+'" />'+name+'</td>';
    	v +='<td></td>';
    	v +='<td></td>';
    	v +='<td></td>';
    	v +='<td><input readonly="readonly" id="zll" class="input ws zl" name="x_number" value="1" /></td>';
    	v +='<td><button type="button" class="btn btn-default delete_a"">删除</button></td>';
    	v +='<td style="display: none"><input id="add" type="hidden" value='+money+'></td>';
    	v +='</tr>';
    	$(".apss").append(v);
    });
    
    
    
    //删除添加行
    $(document).on('click', '.delete_a',function(){
        $(this).parent().parent().remove();
    });
    
    
    
    //总价格
    $('.price').click(function () {
        var cl= $('.i-body').length;
        for (var i=0;i<cl;i++){
            var bcolor = $('.i-body').eq(i).css('display');
            if(bcolor=='block'){
               var ss =  $('.apss').eq(i).children().children().length;
                var arr=[];
                for(var j=1;j<ss;j++){
                    var l =  $('.apss').eq(i).children().children().eq(j).find('#add').val();
                    var lc =  $('.apss').eq(i).children().children().eq(j).find('#zll').val();
                    arr.push(lc*l);
//                  console.log(l)
                }
                var price = eval(arr.join('+'));
                $('.tjp .prs').val(price);
                $('.tjp').show();
                console.log($("#inp").val());
//              $.post('dodoctor',$('.form').serialize(),function(o){
//
//	        	});
            }
        }


    })

    $('.cxp').click(function () {
        $('.tjp').hide();
    })
   
    
    
    //药品搜索添加
    $('.but').click(function(){
    	$(".pagelist").show();
    	var pa=1;
    	$.post('drugserch',{
			dname:$('#yp_search').val(),
			pageNumber:pa
		},function(e){
			$('.tdt').html("");
			var list = e.list;
			$('.pag').text(e.pageNmuber);
			$('.pag2').text(e.pageNmuber+1);
			$("#lable").text(e.pages);
			for(var i=0; i<list.length;i++){
	          	$(".yp_table").append("<tr class='tdt'>"+
	          		"<td>"+list[i].id+"</td>"+
	          		"<td>"+list[i].name+"</td>"+
	          		"<td>"+list[i].spec+"</td>"+
	          		"<td>"+list[i].tory+"</td>"+
	          		"<td>"+list[i].price+"</td>"+
	          		"</tr>"
	          		)
	       	 }
		});
    });
     $(".pags").click(function(){
		var o = parseInt($(".pag").text());
		var pa = o-1;
		if(o==1){
		}else{
			$.post('drugserch',{
				dname:$('#yp_search').val(),
				pageNumber:pa
			},function(e){
				$('.tdt').html("");
				var list = e.list;
				$('.pag').text(e.pageNmuber);
				$('.pag2').text(e.pageNmuber+1);
				for(var i=0; i<list.length;i++){
		          	$(".yp_table").append("<tr class='tdt'>"+
		          		"<td>"+list[i].id+"</td>"+
		          		"<td>"+list[i].name+"</td>"+
		          		"<td>"+list[i].spec+"</td>"+
		          		"<td>"+list[i].tory+"</td>"+
		          		"<td>"+list[i].price+"</td>"+
		          		"</tr>"
		          		)
		       	 }
			});
		}
	});
	$(".pagx").click(function(){
		var o = parseInt($(".pag").text());
		var pa = o+1;
		var page = $("#lable").text();
		if(page==o){
		}else{
			$.post('drugserch',{
				dname:$('#yp_search').val(),
				pageNumber:pa
			},function(e){
				$('.tdt').html("");
				var list = e.list;
				$('.pag').text(e.pageNmuber);
				$('.pag2').text(e.pageNmuber+1);
				for(var i=0; i<list.length;i++){
		          	$(".yp_table").append("<tr class='tdt'>"+
		          		"<td>"+list[i].id+"</td>"+
		          		"<td>"+list[i].name+"</td>"+
		          		"<td>"+list[i].spec+"</td>"+
		          		"<td>"+list[i].tory+"</td>"+
		          		"<td>"+list[i].price+"</td>"+
		          		"</tr>"
		          		)
		       	 }
			});
		}
	});
    
    $('.cut').click(function(){
    	$('.tdu').html("");
    	$.post('proserch',{
			xname:$('#xmser').val()
		},function(e){
		for(var i=0; i<e.length;i++){
	          	$(".xm_table").append("<tr class='tdu'>"+
	          		"<td>"+e[i].id+"</td>"+
	          		"<td>"+e[i].name+"</td>"+
	          		"<td>"+e[i].price+"</td>"+
	          		"</tr>"
	          		)
	       	 }
		});
    });
    
    
</script>
</body>
</html>